home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1993 / Internet Info CD-ROM (Walnut Creek) (1993).iso / networking / ip / sized_io.shar / README < prev    next >
Encoding:
Text File  |  1990-06-29  |  2.8 KB  |  89 lines

  1. This package provides a quick-and-easy means of providing reliable
  2. and large-packet communication between processes.
  3.  
  4. It is described further in the man page stream(3) and at length in the
  5. document by Don Libes entitled "Packet-Oriented Communications Using a
  6. Stream Protocol --or-- Making TCP/IP on Berkeley UNIX a Little More
  7. Pleasant to Use", NISTIR 90-4232, January 1990.
  8.  
  9. It is especially nice because initport() does all the hard work of
  10. initializing TCP connections, and select_server_stream() does the
  11. hard work of connecting processes to each other.
  12.  
  13. If you are running on 4.3BSD, you should add -DBSD4_3 in the Makefile.
  14. Otherwise, this will compile for a 4.2BSD system.
  15.  
  16. To install, type
  17.  
  18.     make install
  19.  
  20. To test, type
  21.  
  22.     make test
  23.     reader
  24.     writer    (in different window)
  25.     writer  (in yet another window)
  26.     writer  (in yet ...)
  27.     and so on.
  28.  
  29.  
  30. reader and writer are two programs that should communicate with
  31. each other.  Type things into any of the writers and reader will
  32. print it out prefaced by the file descriptor the data came in on.
  33.  
  34. Bugs and problems to Don Libes
  35. National Bureau of Standards
  36. Bldg 220, Rm A-127
  37. Gaithersburg, MD  20899
  38. (301) 975-3535
  39.  
  40.  
  41. SYNOPSIS
  42.  
  43. #include <sys/socket.h>
  44. #include <netinet/in.h>
  45. #include <inet.h>
  46.  
  47.     cc [options] [files] sized_io.o stream.o
  48.  
  49. DESCRIPTION
  50.  
  51. This package implements packet or stream IO between a server process and
  52. a number of client processes, using the TCP/IP (stream) facilities.
  53.  
  54. A client uses the call:
  55.  
  56.     s = initport(PORT_NUMBER(XXX),CLIENT,SOCK_STREAM);
  57.  
  58. s is the server's data socket and is used as a file descriptor in further
  59. communication.  The port may be specified by name (PORT_NAME("foo")), if it
  60. is registered.
  61.  
  62. Similarly, the server uses the following call:
  63.  
  64.     s = initport(PORT_NUMBER(XXX),SERVER,SOCK_STREAM);
  65.  
  66. s is the server's connection socket.  To receive data or connections, the
  67. server calls select_server_stream().
  68.  
  69.     client = select_server_stream(s,&fds);
  70.  
  71. This returns a file descriptor corresponding to a client, when a client has
  72. sent a message to the server.  It handles initial connections as well as
  73. client deaths.  s is the server's connection socket that was returned by
  74. initport().  fds is an int used by select...() for storing a bit string
  75. corresponding to client sockets.  Initialize it to 0, and don't mess with it
  76. after that.
  77.  
  78. To use the file descriptors in a stream-oriented manner, use read() and
  79. write().  To use the file descriptors in a packet-oriented manner, use
  80. sized_read() and sized_write().  The sized...() calls read and write one
  81. packet at a time, while packet boundaries are ignored in read() and write().
  82.  
  83.     cc = sized_read(fd,buffer,maxsize)
  84.     cc = sized_write(fd,buffer,size)
  85.  
  86. The arguments for sized_read() and sized_write() are very similar to read()
  87. and write().  The only difference is that in sized_read(), maxsize is the
  88. maximum size of an acceptable packet.
  89.